﻿package com.gy.room;



import java.util.Collections;
import java.util.List;
import java.util.Vector;


import com.google.common.collect.Lists;

import com.gy.room.AbstractRoom;

import io.netty.channel.ChannelHandlerContext;

/**
 * 用户类
 * @author gengyu
 *
 */
/**
 * @author gengyu
 *
 */


public class clientPlayInfo {
	String name;
	int sex;
	String  headUrl;
	int userId;
	ChannelHandlerContext ctx;
    int roomId;
    boolean isOnLine=true;
    /*判断一下断线的时间*/
    float disconnetTime=-1;
    public float getDisconnetTime() {
		return disconnetTime;
	}

	public void setDisconnetTime(float disconnetTime) {
		this.disconnetTime = disconnetTime;
	}

	//0 online 1 livingLine 2 in match mode 3 in room
    int states;
    public int getStates() {
		return states;
	}

	public void setStates(int states) {
		this.states = states;
	}

	public boolean isOnLine() {
		return isOnLine;
	}

	public void setOnLine(boolean isOnLine) {
		this.isOnLine = isOnLine;
	}

	public int getReconnectTimes() {
		return reconnectTimes;
	}

	public void setReconnectTimes(int reconnectTimes) {
		this.reconnectTimes = reconnectTimes;
	}

	int reconnectTimes;
    //开始等待的时间
    private transient long startWaittingTime =-1;
    public long getStartWaittingTime() {
		return startWaittingTime;
	}

	public void setStartWaittingTime(long startWaittingTime) {
		this.startWaittingTime = startWaittingTime;
	}

	

	
	
	public void closeCtx() {
 		if(ctx != null) {
 			try {
 				//Global.logErrorMessage("!!!!!!!!!!!!!关闭连接�?"+getPrimaryKey());
 			    ctx.channel().disconnect();
 				ctx.channel().close();
 			
 				this.ctx = null;
 			} catch (Exception e) {
 			//	Global.logErrorMessage(e);
 			}
 		}
 	}
     
    /*清空玩家的等待时间*/
    public void init()
    {
    	startWaittingTime = System.currentTimeMillis();
    }
     
 	private transient long lastPingTime = System.currentTimeMillis();
 	public void setPing() {
 		this.lastPingTime = System.currentTimeMillis();
 	}
 	//为了测试先把心跳关闭
 	public void checkPingTimeOut() {
// 		if(room == null && System.currentTimeMillis() - this.lastPingTime > 5*GameConstants.MINUTE) {
// 			Global.logErrorMessage(getPrimaryKey()+":ping超时");
// 			UserLogic.getInstance().userLoginOut(this);
// 		}
 	}
    
    
    
    
	public String getName() {
		return name;
	}
	public void setName(String name) {
		this.name = name;
	}
	public int getSex() {
		return sex;
	}
	public void setSex(int sex) {
		this.sex = sex;
	}
	public String getHeadUrl() {
		return headUrl;
	}
	public void setHeadUrl(String headUrl) {
		this.headUrl = headUrl;
	}
	public int getUserId() {
		return userId;
	}
	public void setUserId(int userId) {
		this.userId = userId;
	}
	public ChannelHandlerContext getCtx() {
		return ctx;
	}
	public void setCtx(ChannelHandlerContext ctx) {
		this.ctx = ctx;
	}
	public int getRoomId() {
		return roomId;
	}
	public void setRoomId(int roomId) {
		this.roomId = roomId;
	}
	public long getLastPingTime() {
		return lastPingTime;
	}
	public void setLastPingTime(long lastPingTime) {
		this.lastPingTime = lastPingTime;
	}



    
 
    
    
    
    
}
